import Lockr from 'lockr/lockr.js'
const system = {
    state: {
        appToken: '',
        userToken: '',
        menu: {},
    },
    mutations: {
        saveMenu(state, menu) {
            state.menu = menu
            Lockr.set('menu', state.menu)
        },
        getMenu(state) {
            state.menu = Lockr.get('menu')
        },
        saveAppToken(state, appToken) {
            state.appToken = appToken
            Lockr.set('appToken', state.appToken)
        },
        getAppToken(state) {
            state.appToken = Lockr.get('appToken')
        },
        saveUserToken(state, userToken) {
            state.userToken = userToken
            Lockr.set('userToken', state.userToken)
        },
        getUserToken(state) {
            state.userToken = Lockr.get('userToken')
        },
    },
    actions: {
        saveAppToken({ commit }, appToken) {
            commit('saveAppToken', appToken)
        },
        getAppToken({ commit }) {
            commit('getAppToken')
        },
        saveUserToken({ commit }, userToken) {
            commit('saveUserToken', userToken)
        },
        getUserToken({ commit }) {
            commit('getUserToken')
        },
        saveMenu({ commit }, menu) {
            commit('saveMenu', menu)
        },
        getMenu({ commit }) {
            commit('getMenu')
        }
    }
}

export default system